// component/buy/buy.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    toggle: {
      type: Boolean,
      value: ''
    },
    partData: {
      type: Object,
      value: ''
    },
    goodsid: {
      type: String
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    sum: 1
  },

  /**
   * 组件的方法列表
   */
  methods: {
    showClick(e) {
      const that = this;
      if (e.currentTarget.dataset.sole == "sole") {
        that.setData({
          toggle: true,
          sum: 1
        })
      }
    },
    getCount(e) {
      const that = this;
      that.setData({
        sum: e.detail.val
      })
    },
    addCart(e) {
      const that = this;
      let sum = that.data.sum;
      that.triggerEvent('addCart', sum)
      if (e.currentTarget.dataset.sole == "sole") {
        that.setData({
          toggle: true,
          sum: 1
        })
      }
    },
    cancel() {
      const that = this;
      that.setData({
        toggle: true,
        sum: 1
      })
    },
    _toFillOrder() {
      const that = this;
      let param = {
        goodsid: that.data.goodsid,
        goodsnum: that.data.sum
      }
      that.triggerEvent('toFillOrder', param)
    }

  }

})